package collection;

import java.util.*;

public class Work {
    public static void main(String[] args) {
        /*
        Collection<Point> c = new ArrayList<>();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));
        System.out.println(c);

        System.out.println("size:"+c.size());
        System.out.println("是否为空集："+c.isEmpty());

         */
        /*
        c.clear();
        System.out.println("已清空合集");
         */
        /*
        Point p = new Point(1,2);
        boolean contains = c.contains(p);
        System.out.println("是否包含："+contains);

        c.remove(p);
        System.out.println(c);

        Collection<String> s1 = new ArrayList<>();
        s1.add("java");
        s1.add("math");
        s1.add("c++");
        System.out.println("s1:"+s1);

        Collection<String> s2 = new ArrayList<>();
        s2.add("ios");
        s2.add("android");
        s2.add("php");
        System.out.println("s2:"+s2);

        s1.addAll(s2);
        System.out.println("s1:"+s1);
        System.out.println("s2:"+s2);

        Collection<String> s3 = new ArrayList<>();
        s3.add("ios");
        s3.add("java");
        s3.add("c++");
        System.out.println("s3:"+s3);

        boolean contains1 = s1.containsAll(s3);
        System.out.println("是否包含:"+contains1);

         */
        /*
        s1.retainAll(s3);
        System.out.println("s1:"+s1);
        System.out.println("s3:"+s3);
         */
        /*
        s1.removeAll(s3);
        System.out.println("s1:"+s1);
        System.out.println("s3:"+s3);

        Collection<String> s4 = new ArrayList<>();
        s4.add("a");
        s4.add("b");
        s4.add("c");
        s4.add("d");
        s4.add("e");
        Iterator<String> it = s4.iterator();
        while (it.hasNext()){
            String str = it.next();
            System.out.println(str);
        }
        for (String str : s4){
            System.out.println(str);
        }

        String[] array = s4.toArray(new String[5]);
        System.out.println(Arrays.toString(array));

        String[] array1 = {"a","b","c","d","e"};
        System.out.println("array:"+Arrays.toString(array1));
        List<String> list = Arrays.asList(array1);
        System.out.println("list:"+list);

         */
        Collection<Point> c = new ArrayList<>();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));
        System.out.println(c);
        System.out.println("size:"+c.size());
        System.out.println("是否为空集:"+c.isEmpty());
        /*
        c.clear();
        System.out.println("已清空合集");
         */
        Point p = new Point(1,2);
        boolean contains = c.contains(p);
        System.out.println("是否包含:"+contains);

        c.remove(p);
        System.out.println(c);

        Collection<String> s1 = new ArrayList<>();
        s1.add("java");
        s1.add("c++");
        s1.add(".net");
        System.out.println("s1:"+s1);

        Collection<String> s2 = new ArrayList<>();
        s2.add("android");
        s2.add("ios");
        s2.add("math");
        System.out.println("s2:"+s2);

        s1.addAll(s2);
        System.out.println("s1:"+s1);
        System.out.println("s2:"+s2);

        Collection<String> s3 = new ArrayList<>();
        s3.add("java");
        s3.add("c++");
        s3.add("php");
        System.out.println("s3:"+s3);
        boolean contains1 = s1.containsAll(s3);
        System.out.println("是否包含："+s1.containsAll(s3));
        /*
        s1.retainAll(s3);
        System.out.println("s1:"+s1);
        System.out.println("s3:"+s3);
         */
        s1.removeAll(s3);
        System.out.println("s1:"+s1);
        System.out.println("s3:"+s3);

        Collection<String> c1 = new ArrayList<>();
        c1.add("a");
        c1.add("b");
        c1.add("c");
        c1.add("d");
        c1.add("e");
        Iterator<String> it = c1.iterator();
        while (it.hasNext()){
            String str = it.next();
            System.out.println(str);
        }
        for (String str : c1){
            System.out.println(str);
        }

        String[] array =c1.toArray(new String[5]);
        System.out.println(Arrays.toString(array));

        String[] array1 = {"a","b","c","d","e"};
        System.out.println("array:"+Arrays.toString(array1));
        List<String> list = Arrays.asList(array1);
        System.out.println("list:"+list);











    }
}
